import { FormRule } from 'tdesign-vue-next';
import { ref } from 'vue';
import { PrimaryTableCol, TableRowData } from 'tdesign-vue-next';
import { TRANSPORT_PROTOCAL_OPTIONS } from '@/constants/data'

export const INIT_DATA: any = { sn: '', dev_name: '', time: [] };
const protocolVersionOptions = [
  { label: 'GB/T28181-2016', value: 1 }
]
export const list = ref([
  { label: 'GB28181启用禁用', value: false, key: 'enable', type: 'SwitchView' },
  { label: '传输协议', value: 1, key: 'transport_protocol', type: 'SelectView', options: TRANSPORT_PROTOCAL_OPTIONS },
  { label: '协议版本', value: 1, key: 'protocol_version', type: 'SelectView', options: protocolVersionOptions },
  { label: '本地SIP端口', value: '', key: 'SIP_port', type: 'InputView', placeholder: '请输入本地SIP端口端口', clearable: true },
  { label: 'SIP服务器ID', value: '', key: 'SIP_server_id', type: 'InputView', placeholder: '请输入SIP服务器ID', clearable: true },
  { label: 'SIP服务器域', value: '', key: 'SIP_server_field', type: 'InputView', placeholder: '请输入SIP服务器域', clearable: true },
  { label: 'SIP服务器地址', value: '', key: 'SIP_server_adr', type: 'InputView', placeholder: '请输入SIP服务器地址', clearable: true },
  { label: 'SIP服务器端口', value: '', key: 'SIP_server_port', type: 'InputView', placeholder: '请输入SIP服务器端口', clearable: true },
  { label: 'SIP用户名', value: '', key: 'SIP_username', type: 'InputView', placeholder: '请输入SIP用户名', clearable: true },
  { label: 'SIP用户认证ID', value: '', key: 'SIP_authentication_id', type: 'InputView', placeholder: '请输入SIP用户认证ID', clearable: true },
  { label: 'SIP用户认证密码', value: '', key: 'SIP_authentication_password', type: 'InputView', inputType: 'password', placeholder: '请输入SIP用户认证密码', clearable: true },
  { label: '认证密码确认', value: '', key: 'authentication_password_confirm', type: 'InputView', inputType: 'password', placeholder: '请输入认证密码确认', clearable: true },
  { label: '注册有效期', value: '', key: 'registration_validity_period', type: 'InputAdornmentView', inputType: 'number', placeholder: '请输入注册有效期', append: 'S', clearable: true },
  { label: '心跳周期', value: '', key: 'heartbeat_cycle', type: 'InputAdornmentView', inputType: 'number', placeholder: '请输入心跳周期', append: 'S', clearable: true },
  { label: '最大心跳超时次数', value: '', key: 'heartbeat_timeout_count', type: 'InputAdornmentView', inputType: 'number', placeholder: '请输入最大心跳超时次数', append: '次', clearable: true },
]);

export const FORM_RULES: Record<string, FormRule[]> = {
  enable: [{ required: true, message: '请选择', trigger: 'blur' }],
  server_adr: [{ required: true, message: '请输入目标服务器地址', trigger: 'blur' }],
  server_port: [{ required: true, message: '请输入目标服务器端口', trigger: 'blur' }],
};

export const columns: PrimaryTableCol<TableRowData>[] = [
  { colKey: 'dev_name', title: '设备名称', align: 'center' },
  { colKey: 'enable', title: 'GA1400启用禁用', align: 'center' },
  { colKey: 'connect_status', title: '连接状态', align: 'center' },
  { colKey: 'opt', title: '操作', fixed: 'right', align: 'center' },
];
